package com.effect.GOP.Factory;

/**
 * Created by Administrator on 2017/1/3.
 */
//首先是抽象产品接口
interface Light {
    public void trunOn();

    public void turnOff();
}

//     下面是具体的产品
class BuildLight implements Light {

    @Override
    public void trunOn() {
        System.out.println("BuildLight On");
    }

    @Override
    public void turnOff() {
        System.out.println("BuildLight off");
    }
}


class TubeLight implements Light {

    @Override
    public void trunOn() {
        System.out.println("TubeLight On");
    }

    @Override
    public void turnOff() {
        System.out.println("TubeLight Off");
    }
}

//抽象的工厂接口
interface Creator {
    public Light createLight();
}

/**
 * 创建具体的工厂
 */
class BuildCreator implements Creator {

    @Override
    public Light createLight() {
        return new BuildLight();
    }
}

class TubeCreator implements Creator {
    @Override
    public Light createLight() {
        return new TubeLight();
    }
}

public class ClientDemo {
    public static void main(String[] args) {
        Creator creator = new BuildCreator();
        Light light = creator.createLight();
        light.trunOn();
        light.turnOff();

        creator = new TubeCreator();
        light = creator.createLight();
        light.trunOn();
        light.turnOff();
    }
}
